﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XTYAPI.PLC
{
    /// <summary>
    /// 与运算
    /// </summary>
    public class And
    {
        /// <summary>
        /// 与过程存储
        /// </summary>
        public List<bool> Ands { get; set; }
        /// <summary>
        /// 计算与结果
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public bool CalAnd()
        {
            if (Ands.Count<1)
            {
                throw new Exception("至少需要1个bool量进行与预算");
            }
            foreach (var item in Ands)
            {
                if (!item)
                {
                    return false;
                }        
            }
            return true;
        }
    }
}
